package com.example.service;

import com.example.mapper.EmployeeMapper;
import com.example.pojo.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    public List<Employee> getEmployees(int page, int limit) {
        int offset = (page - 1) * limit;
        return employeeMapper.getEmployees(limit, offset);
    }

    public int getTotalEmployees() {
        return employeeMapper.getTotalEmployees();
    }

    public Employee getEmployeeById(String employeeId) {

        return employeeMapper.getEmployeeById(employeeId);
    }

    public List<Employee> getEmployeeByName(String name, int offset, int limit) {
        return employeeMapper.getEmployeeByName(name, offset, limit);
    }

    public int countEmployeesByName(String name) {
        return employeeMapper.countEmployeesByName(name);
    }
}
